package com.homedo.odin.solution.controller.mng;

import com.homedo.core.common.base.controller.BaseController;
import com.homedo.core.common.base.dto.Meta;
import com.homedo.core.common.base.dto.ResultData;
import com.homedo.core.common.exception.BizException;
import com.homedo.core.common.util.NumberHelper;
import com.homedo.odin.solution.contract.mng.UserRequirePriResponseBean;
import com.homedo.odin.solution.contract.pc.OmsFinanceListResponseBean;
import com.homedo.odin.solution.service.bizservice.mng.MngFinanceManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: ZhangLei
 * @date: 2018/4/9
 * @Description:
 */
@Api(description = "Manage_财务管理相关信息模块", tags = {"OMS FinanceManage"},
        produces = MediaType.APPLICATION_JSON_VALUE)
@RestController
@RequestMapping("/mng")
public class MngFinanceManageController extends BaseController<MngFinanceManageService> {

    @GetMapping("income")
    @ApiOperation(value = "mng_查询入款列表", response = UserRequirePriResponseBean.class, httpMethod = "GET")
    public ResultData querySpecificationListByParams(
            @ApiParam(value = "购买类型 1：方案 2：行业规范", required = false) @RequestParam(value = "businessType", required = false) Integer businessType,
            @ApiParam(value = "创建时间(开始)", required = false) @RequestParam(value = "startCreatTime", required = false) Long startCreatTime,
            @ApiParam(value = "创建时间(结束)", required = false) @RequestParam(value = "endCreateTime", required = false) Long endCreateTime,
            @ApiParam(value = "当前页码", required = true) @RequestParam("pageNum") Integer currentPage,
            @ApiParam(value = "每页记录数", required = true) @RequestParam("pageSize") Integer pageSize) {
        if (!NumberHelper.validate(currentPage) || !NumberHelper.validate(pageSize)) {
            throw new BizException(Meta.CODE_451.getCode(), "pageNum pageSize参数非法");
        }

        OmsFinanceListResponseBean responseBean = baseService
                .queryFinancialListForPri(businessType, startCreatTime, endCreateTime, currentPage, pageSize);
        return ResultData.newInstance(Meta.CODE_200, responseBean);
    }
}
